public class IsValidSudoku {

    public boolean solution(char[][] board){
        int length=board.length;
        int[][] cell=new int[length][length];
        int[][] row=new int[length][length];
        int[][] cellRow=new int[length][length];

        for (int i = 0; i < length; i++) {
            for (int j = 0; j < length; j++) {
                if(board[i][j]=='.'){
                    continue;
                }
                int num=board[i][j]-'0'-1;
                int k=i/3*3+j/3;
                if(cell[i][num]!=0||row[j][num]!=0||cellRow[k][num]!=0){
                    return false;
                }
                cell[i][num]=row[j][num]=cellRow[k][num]=1;
            }
        }
        return true;
    }
}
